from mnist_data import load_mnist
import numpy as np
from Two_Layer_Net import *
(x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, one_hot_label=True)
network = TwoLayerNet(input_size=784, hidden_size=50, output_size=10)
x_batch,t_batch = x_train[:3], t_train[:3]
grad_numerical=network.numerical_gradient(x_batch, t_batch)
grad_back=network.gradient(x_batch, t_batch)
for key in grad_numerical.keys():
    diff=np.average(np.abs(grad_numerical[key]-grad_back[key]))
    print(key,diff)